package com.idbk.chargestation.bean;

import com.google.gson.annotations.SerializedName;

import java.util.Date;
import java.util.List;
import java.util.Locale;

public class JsonMywalletRecord extends JsonBase{
	
	/**
	 * 交易状态：完成
	 */
	public final static int RECHARGE_STATUS_FINISH = 0;
	/**
	 * 交易状态：等待
	 */
	public final static int RECHARGE_STATUS_WAITING = 1;
	/**
	 * 交易状态：取消
	 */
	public final static int RECHARGE_STATUS_CANCEL = 2;
	/**
	 * 交易状态：订单失效
	 */
	public final static int RECHARGE_STATUS_UNAVAILABLE = 3;
	
	/**
	 * 记录类型：全部
	 */
	public final static int RECORD_TYPE_ALL = 0;
	/**
	 * 记录类型：充值
	 */
	public final static int RECORD_TYPE_RECHARGE = 8;
	/**
	 * 记录类型：消费
	 */
	public final static int RECORD_TYPE_CONSUME = 16;

	/**
	 * 账单类型：消费
	 */
	public final static int CONSUMPTION = 1;

	/**
	 * 账单类型：充值
	 */
	public final static int RECHARGE = 2;

	/**
	 * 账单类型：充值
	 */
	public final static int PRESENTED = 3;

	/**
	 * 账单具体类型：赠送
	 */
	public final static int CHARGE_CONSUMPTION = 1;

	/**
	 * 账单具体类型：预约消费
	 */
	public final static int PREPARED_CONSUMPTION = 2;

	/**
	 * 账单具体类型：支付宝充值
	 */
	public final static int ALIPAY_RECHARGE = 3;

	/**
	 * 账单具体类型：微信充值
	 */
	public final static int WECHAT_RECHARGE = 4;

	/**
	 * 账单具体类型：后台赠送
	 */
	public final static int BACKGROUND_PRESENTED = 5;

	/**
	 * 账单具体类型：充值赠送
	 */
	public final static int RECHARGE_PRESENTED = 6;

	/**
	 * 账单具体类型：介绍赠送
	 */
	public final static int INTRODUCTION_PRESENTED = 7;

	/**
	 * 账单具体类型：注册赠送
	 */
	public final static int REGISTRATION_PRESENTED = 8;

	/**
	 * 账单具体类型：停车费
	 */
	public final static int PARKING_CHARGE = 10;

	/**
	 * 账单具体类型：退款
	 */
	public final static int REFUND = 16;

	@SerializedName("tradingType")
	public int tradingType ;//交易类型
	
	@SerializedName("tradingLogId")
	public int tradingLogId;//账单ID
	
	@SerializedName("bookTime")
	public int bookTime;//预约时长
	
	@SerializedName("chargeTime")
	public int chargeTime;//充电时长
	
	@SerializedName("bespeakMoney")
	public double bespeakMoney;//预约费用
	
	@SerializedName("chargeMoney")
	public double chargeMoney;//充电费用
	
	@SerializedName("serviceMoney")
	public double serviceMoney;//服务费用
	
	@SerializedName("detailType")
	public int detailType;//消费类型
	
	@SerializedName("money")
	public double money;//消费金额s
	
	@SerializedName("pileSn")
	public String pileSn;//电桩序列号
	
	@SerializedName("pointName")
	public String pointName;//充电桩名称
	
	@SerializedName("recordTime")
	public String recordTime;//记录时间
	
	@SerializedName("rechargeStatus")
	public int rechargeStatus;//充值订单 交易状态
	
	@SerializedName("tradingNo")
	public String tradingNo;//交易流水号
	
	@SerializedName("chargeMoneys")
	public List<JsonChargeMoney> chargeMoneys;
	
	@SerializedName("sumQuantity")
	public double sumQuantity;//总充电量，2位小数
	
	@SerializedName("startChargeTime")
	public String startChargeTime;//开始充电时间
	
	@SerializedName("stopChargeTime")
	public String stopChargeTime;//结束充电时间
	
	@SerializedName("startBookTime")
	public Date startBookTime;//开始预约时间
	
	@SerializedName("stopBookTime")
	public Date stopBookTime;//结束预约时间
	
	@SerializedName("rechargeMoney")
	public double rechargeMoney;//充值金额，小数点2位
	
	@SerializedName("giftMoney")
	public double giftMoney;//赠送金额，小数点2位
	
	@SerializedName("startParkingTime")
	public Date startParkingTime;//开始停车时间
	
	@SerializedName("stopParkingTime")
	public Date stopParkingTime;//结束停车时间
	
	@SerializedName("parkingMoney")
	public double parkingMoney;//停车金额
	
	
	public String totalChargeMoney() {
		double sum = 0.0f;
		for (JsonChargeMoney money : chargeMoneys) {
			sum += money.cost;
		}
		return String.format(Locale.CHINA, "%.2f", sum);
	}

	public String getStartChargeTime() {
		if (startChargeTime == null || "".equals(startChargeTime)) {
			return " —— ";
		}
		return startChargeTime;
	}

	public String getStopChargeTime() {
		if (stopChargeTime == null || "".equals(stopChargeTime)) {
			return " —— ";
		}
		return stopChargeTime;
	}
}
